// 创建系统表
export function createSysTb(info) {
	console.log('创建系统表: ');
	plus.sqlite.executeSql({
		name: 'fire',
		sql: 'create table if not exists sys("id" number PRIMARY KEY, "check" CHAR(5))',
		success: function(e) {
			plus.sqlite.executeSql({
				name: 'fire',
				sql: 'insert into sys values(0, "0")',
				success: function() {
					console.log('创建系表成功!');
				},
				fail: function(e) {
					// console.log('已存在初始数据!' + JSON.stringify(e));
					console.log('已存在初始数据!');
				}
			})
		},
		fail: function(e) {
			reject(e);
			console.log('创建系统表失败: ' + JSON.stringify(e));
		}
	});
};

// 获取检查标记
export function selectCheckSet() {
	console.log('获取检查标记: ')
	return new Promise((resolve, reject) => {
		plus.sqlite.selectSql({
			name: 'fire',
			sql: 'select `check` from sys',
			success: function(data) {
				console.log(data[0].check);
				resolve(data[0].check);
				console.log('检查标记成功!');
			},
			fail: function(e) {
				reject(e);
				console.log('检查标记失败: ' + JSON.stringify(e));
			}
		});
	})
};

// 检查标记设置
export function checkSet(check) {
	console.log('检查标记设置: ');
	plus.sqlite.executeSql({
		name: 'fire',
		sql: 'update sys set `check` = "' + check + '"',
		success: function() {
			console.log('检查标记成功设置!');
		},
		fail: function(e) {
			reject(e);
			console.log('检查标记失败: ' + JSON.stringify(e));
		}
	});
};
